import Vuex from "vuex";
export default async ({ Vue, isServer }) => {
  Vue.use(Vuex);
  if (!isServer) {
    import('firefly-web-ui/lib/theme-chalk/index.css');
    await import("firefly-web-ui").then((module) => {
      Vue.use(module.default);
      Vue.mixin({ store: module.store });
    });
    import('firefly-web-component/lib/style/index.css');
    await import("firefly-web-component").then((module) => {
      Vue.use(module.default);
      Vue.mixin({ store: module.store });
    });
    document.getElementById("app");
  }
  Vue.mixin({
    mounted() {
      if (this.$route && this.$route.path) {
        let pageRoot = this.$route.path.split(".")[0];
        if (this.$themeConfig.simulatorUrl[pageRoot]) {
          try {
            document
              .getElementById("app");
          } catch (e) {
            console.log(e);
            //TODO handle the exception
          }
        } else {
          try {
            document
              .getElementById("app");
          } catch (e) {
            console.log(e);
            //TODO handle the exception
          }
        }
      }
    },
  });
};
